package org.the.gsdo.server;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.the.gsdo.shared.SendTextToServer;
import org.the.gsdo.shared.SendTextToServerResult;

@Component
@Lazy(true)
@Scope("request")
@Profile("prod")
public class GreetingManagerProd extends GreetingManagerBase implements GreetingManager {

	private final HttpDataProvider httpDataProvider;

	// AOP (proxying ... super needs void constructor)
	public GreetingManagerProd() {
		this(null, null);
	}

	@Autowired
	public GreetingManagerProd(
			HttpDataProvider httpDataProvider,
			@Qualifier("propertyProvider") PropertyProvider propertyProvider) {
		super(propertyProvider);
		this.httpDataProvider = httpDataProvider;
	}

	@Override
	@LogAction("GreetingManagerProd.execute(SendTextToServer ...)")
	@Transactional(readOnly=false)
	public SendTextToServerResult execute(SendTextToServer action) {
		return new SendTextToServerResult(greetServerX(
				action.getTextToServer(),
				httpDataProvider.getServerInfo(),
				null));
	}

}
